import { createRouter, createWebHistory } from 'vue-router'
import menuRouter from './menu-router'
import tool from '@/utils/tool';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/dashboard',
    },
    {
      path: '/dashboard',
      name: 'Layout',
      component: () => import('@/layout/index.vue'),
      children: menuRouter
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/user/Login.vue'),
    },
  ]
})

// router.beforeEach(async (to, from, next) => {

//   const token = tool.data.get("TOKEN");

//   if (to.name !== 'Login' && !token) next({ name: 'Login' })
//   else next()

// })

export default router
